#ifndef CCRC32_H
#define CCRC32_H

#include <stddef.h>
#include <stdint.h>

class CCRC32
{
public:
	~CCRC32() {}
	void initCRC32Table();
	uint64_t getCRC(unsigned char* buffer, unsigned int dwSize);

	static CCRC32* getInstance() {
		if (m_pInstance == NULL)
		{
			if (m_pInstance == NULL) {
				m_pInstance = new CCRC32();
				static CGarbageCollector clGarColl;
			}
		}
		return m_pInstance;
	}

	class CGarbageCollector {
	public:
		~CGarbageCollector() {
			if (CCRC32::m_pInstance)
			{
				delete CCRC32::m_pInstance;
				CCRC32::m_pInstance = NULL;
			}
		}
	};
private:
	CCRC32();
	unsigned int m_szCRC32Table[256];
	static CCRC32* m_pInstance;
};

#endif